package com.chery.media.ui.setting.language

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.chery.media.R

class LanguageAdapter: BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_setting_language) {

    private var index = 0

    override fun convert(holder: BaseViewHolder, item: String) {
        holder.apply {
            setText(R.id.languageText, item)
            setTextColorRes(R.id.languageText, if (index == layoutPosition) R.color.public_FDCD19 else  R.color.public_FFFFFF)
            itemView.setBackgroundResource(if (index == layoutPosition) R.color.public_1AFDCD19 else R.color.transparent)
        }
    }

    fun setIndex(position: Int){
        this.index = position
        notifyDataSetChanged()
    }
}